//
//  EyuReportBridge.m
//  QySDKBridge
//
//  Created by lcc on 2025/2/10.
//

#import "EyuReportBridge.h"
#import <EyuGameSDK/AboGameSDKApi.h>
#import <QySDKBridge/SDKBridgeUtil.h>
#import "EyuHeader.h"
NSString * const SERVER_ID = @"1";
NSString * const SERVER_NAME = @"None";
NSString * const ROLE_NAME_PREFIX = @"Player_";
NSString * const ROLE_LEVEL = @"1";
NSString * const VIP_LEVEL = @"0";

@implementation EyuReportBridge

+ (void)eventReport:(NSString *)eventName propertiesJson:(NSString *)propertiesJson{
    NSDictionary* dict = [SDKBridgeUtil JsonToDict:propertiesJson];
    [self eventReport:eventName dict:dict];
}

+ (void)eventReport:(NSString *)eventName dict:(NSDictionary *)dict{
    NSLog(@"--->>> EyuReportBridge - eventReport - eventName:%@", eventName);
    NSDictionary* baseDict = [EyuReportBridge AddBaseParams];
    NSMutableDictionary* totalDict = [NSMutableDictionary dictionaryWithDictionary:baseDict];
    [totalDict addEntriesFromDictionary:dict];
    [[AboGameSDKApi SDKManager]GameTrackEvent:eventName withValues:totalDict];
}

+ (NSDictionary *)AddBaseParams{
    if ([EyuHeader Instance].m_UserId==nil) {
        NSLog(@"上报时uid发现为空");
    }
    NSDictionary* dict = @{
        @"user_id": [EyuHeader Instance].m_UserId?:@"",
        @"role_id": [EyuHeader Instance].m_UserId?:@"",
        @"role_name": [ROLE_NAME_PREFIX stringByAppendingFormat:@"%@", [EyuHeader Instance].m_UserId?:@""],
        @"server_id": SERVER_ID,
        @"server_name":  SERVER_NAME,
        @"role_level": ROLE_LEVEL,
        @"vip_level": VIP_LEVEL };
    return dict;
}

@end
